package com.lsm.composite;

import java.util.Iterator;
import java.util.Vector;

public class Directory extends Entry {

	private String name;

	private Vector<Entry> directory = new Vector<Entry>();

	public Directory(String name) {
		this.name = name;
	}

	public String getName() {
		return name;
	}

	public int getSize() {
		int size = 0;
		Iterator<Entry> iter = directory.iterator();
		while (iter.hasNext()) {
			size += iter.next().getSize();
		}
		return size;
	}

	public void add(Entry entry) throws Exception {
		directory.add(entry);
	}

	public void printFile() {
		Iterator<Entry> iter = directory.iterator();
		while (iter.hasNext()) {
			Entry entry = iter.next();
			entry.printFile();
		}
	}

}
